#!/bin/bash

# 定义变量方便修改
table_db=cy_database 
hive=/home/software/hive-2.3.6/bin/hive

# 如果是输入的日期按照取输入日期；如果没输入日期取当前时间的前一天
if [ -n "$1" ] ;then
	do_date=$1
else 
	do_date=`date -d "-1 day" +%F`  
fi 

sql="
with
tmp_job_fair  as(
	select \
		id,
		hold_date,
		hold_address,
		week_day,
		job_fair_type,
		key_service_type,
		enterprise_sum,
		position_sum,
		admission_sum,
		reach_work_sum,
		sign_ldht_sum,
		work_person,
		job_fair_name
	from cy_database.dwd_job_fair jf
	where jf.dt='2020-06-17' and jf.id is not null


)

insert overwrite table cy_database.dws_job_fair  partition(dt='2020-06-17')
	select
		id,
		hold_date,
		hold_address,
		week_day,
		job_fair_type,
		key_service_type,
		enterprise_sum,
		position_sum,
		admission_sum,
		reach_work_sum,
		sign_ldht_sum,
		work_person,
		job_fair_name
	from tmp_job_fair
;



"
$hive -e "$sql"